package com.sgb.kjwl.view.ui.adapter.transport;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.transport.GoodsInfoEntity3;
import com.sgb.kjwl.view.ui.activity.transport.GoodsInfoOrderPriceListActivity3;
import com.swgk.core.dialog.RoundCornerDialog;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class GoodsInfoManagerListAdapter3 extends BaseRecycleAdapter<GoodsInfoEntity3> {


    public GoodsInfoManagerListAdapter3(Context context, List<GoodsInfoEntity3> datas) {
        super(context, R.layout.item_goods_info_manager_adapter3, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, GoodsInfoEntity3 goodsInfoEntity3) {
        holder.setBinding(BR.viewModel,goodsInfoEntity3);

        LinearLayout layout = (LinearLayout) holder.getItem().findViewById(R.id.order_driver);

        layout.setOnClickListener(view -> {
            GoodsInfoOrderPriceListActivity3.start(context);
        });

        TextView tvEdit = holder.getItem().findViewById(R.id.view_edit);
        tvEdit.setOnClickListener(view -> {

        });

        TextView tvDelete = holder.getItem().findViewById(R.id.view_delete);
        tvDelete.setOnClickListener(view -> {
            showDialog();
        });
    }

    public void showDialog() {
        View view = View.inflate(context, R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(context, 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失

        TextView tv_message = (TextView) view.findViewById(R.id.tv_message);
        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_logout_confirm = (TextView) view.findViewById(R.id.tv_logout_confirm);
        tv_title.setVisibility(View.VISIBLE);
        TextView tv_logout_cancel = (TextView) view.findViewById(R.id.tv_logout_cancel);
        tv_title.setText("删除确认");
        tv_message.setText("确定删除吗???");

        //确定
        tv_logout_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                roundCornerDialog.dismiss();
            }
        });

        //取消
        tv_logout_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                roundCornerDialog.dismiss();
            }
        });
    }
}
